import { lazy, Suspense } from "react";
import { Navigate, useRoutes } from "react-router-dom";
import Login from "../pages/login";
import Home from "../pages/home";
// 首页
const Homepage = lazy(() => import('../pages/home/homepage'))
const TodayBillboard = lazy(() => import('../pages/home/homepage/todayBillboard'))
const QualityBillboard = lazy(() => import('../pages/home/homepage/qualityBillboard'))
// 物料派单
const MaterialSingle = lazy(() => import('../pages/home/materialSingle'))
const Wms = lazy(() => import('../pages/home/materialSingle/Wms'))
// 物料检验
const MaterialMaterial = lazy(() => import('../pages/home/materialMaterial'))
// 检验结果
const InspectionResult = lazy(() => import('../pages/home/inspectionResult'))
//检验结果:第一个页面的维护
const Maintain1 = lazy(() => import('../pages/home/inspectionResult/maintai1'))
const Maintain2 = lazy(() => import('../pages/home/inspectionResult/maintai2'))
const Maintain = lazy(() => import('../pages/home/inspectionResult/maintain'))
const SupervisorAudit = lazy(() => import('../pages/home/inspectionResult/supervisorAudit'))
// 综合查询
const ComprehensiveInquiry = lazy(() => import('../pages/home/comprehensiveInquiry'))
// 综合查询:编辑
const Redact = lazy(() => import('../pages/home/comprehensiveInquiry/redact'))
const Details = lazy(() => import('../pages/home/comprehensiveInquiry/details'))
// 定点信息
const DotMessage = lazy(() => import('../pages/home/dotMessage'))
const DotMaterial = lazy(() => import('../pages/home/dotMessage/dotMaterial'))
// 基础管理
const BasicManagement = lazy(() => import('../pages/home/basicManagement'))
const MaterialManagement = lazy(() => import('../pages/home/basicManagement/materialManagement'))
const ProjectStandard = lazy(() => import('../pages/home/basicManagement/projectStandard'))
const InspectionItem = lazy(() => import('../pages/home/basicManagement/inspectionItem'))
const SamplingPlan = lazy(() => import('../pages/home/basicManagement/samplingPlan'))
const DataDictionary = lazy(() => import('../pages/home/basicManagement/dataDictionary'))
// 资产管理
const AssetsManagement = lazy(() => import('../pages/home/assetsManagement'))
// 分析报表
const AnalyticalStatement = lazy(() => import('../pages/home/analyticalStatement'))
const VendorAnalysis = lazy(() => import('../pages/home/analyticalStatement/vendorAnalysis'))
const YieldAnalysis = lazy(() => import('../pages/home/analyticalStatement/yieldAnalysis'))
// 绩效管理
const PerformanceManagement = lazy(() => import('../pages/home/performanceManagement'))
// 权限管理
const AuthorityManagement = lazy(() => import('../pages/home/authorityManagement'))
const UserControl = lazy(() => import('../pages/home/authorityManagement/userControl'))
const MailManagement = lazy(() => import('../pages/home/authorityManagement/mailManagement'))
const MailEditor = lazy(() => import('../pages/home/authorityManagement/mailManagement/maliEditor'))
const AutoSingle = lazy(() => import('../pages/home/authorityManagement/autoSingle'))
// 帮助中心
const HelpCenter = lazy(() => import('../pages/home/HelpCenter'))
const Routers = () => useRoutes([
  {
    path: '/',
    element: <Navigate to="/login" />
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '/home',
    element: <Home />,
    children: [
      {
        path: '/home/first',
        children: [
          // 首页-
          {
            path: '/home/first/homepage',
            element: <Suspense fallback={<div>Loading...</div>}>
              <Homepage />
            </Suspense>,
          },
        ]
      },
      {
        path: '/home/second',
        children: [
          // 物料派单-
          {
            path: '/home/second/materialSingle',
            element: <Suspense fallback={<div>Loading...</div>}>
              <MaterialSingle />
            </Suspense>
          },
          // 物料派单: wms待派单
          {
            path: '/home/second/Wms',
            element: <Suspense fallback={<div>Loading...</div>}>
              <Wms />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/thirdly',
        children: [
          // 物料检验-
          {
            path: '/home/thirdly/materialMaterial',
            element: <Suspense fallback={<div>Loading...</div>}>
              <MaterialMaterial />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/fourthly',
        children: [
          // 检验结果-
          {
            path: '/home/fourthly/inspectionResult',
            element: <Suspense fallback={<div>Loading...</div>}>
              <InspectionResult />
            </Suspense>
          },
          {
            path: '/home/fourthly/maintain/:id',
            element: <Suspense fallback={<div>Loading...</div>}>
              <Maintain />
            </Suspense>
          },
          {
            path: '/home/fourthly/maintain1/:id',
            element: <Suspense fallback={<div>Loading...</div>}>
              <Maintain1 />
            </Suspense>
          },
          {
            path: '/home/fourthly/maintain2/:id',
            element: <Suspense fallback={<div>Loading...</div>}>
              <Maintain2 />
            </Suspense>
          },
          // 检验结果:质量主管审核
          {
            path: '/home/fourthly/supervisorAudit',
            element: <Suspense fallback={<div>Loading...</div>}>
              <SupervisorAudit />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/fifth',
        children: [
          // 综合查询-
          {
            path: '/home/fifth/comprehensiveInquiry',
            element: <Suspense fallback={<div>Loading...</div>}>
              <ComprehensiveInquiry />
            </Suspense>
          },
          // 综合查询:编辑
          {
            path: '/home/fifth/redact',
            element: <Suspense fallback={<div>Loading...</div>}>
              <Redact />
            </Suspense>
          },
          {
            path: '/home/fifth/details',
            element: <Suspense fallback={<div>Loading...</div>}>
              <Details />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/sixth',
        children: [
          // 定点信息-
          {
            path: '/home/sixth/dotMessage',
            element: <Suspense fallback={<div>Loading...</div>}>
              <DotMessage />
            </Suspense>
          },
          // 定点信息: 定点物料
          {
            path: '/home/sixth/dotMaterial',
            element: <Suspense fallback={<div>Loading...</div>}>
              <DotMaterial />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/seventh',
        children: [
          // 基础管理-
          {
            path: '/home/seventh/basicManagement',
            element: <Suspense fallback={<div>Loading...</div>}>
              <BasicManagement />
            </Suspense>
          },
          // 基础管理:物料管理
          {
            path: '/home/seventh/materialManagement',
            element: <Suspense fallback={<div>Loading...</div>}>
              <MaterialManagement />
            </Suspense>
          },
          //基础管理:项目标准
          {
            path: '/home/seventh/ProjectStandard',
            element: <Suspense fallback={<div>Loading...</div>}>
              <ProjectStandard />
            </Suspense>
          },
          // 基础管理:检验项目
          {
            path: "/home/seventh/inspectionItem",
            element: <Suspense fallback={<div>Loading...</div>}>
              <InspectionItem />
            </Suspense>
          },
          // 基础管理:抽样方案
          {
            path: '/home/seventh/samplingPlan',
            element: <Suspense fallback={<div>Loading...</div>}>
              <SamplingPlan />
            </Suspense>
          },
          // 基础管理:数据字典
          {
            path: '/home/seventh/dataDictionary',
            element: <Suspense fallback={<div>Loading...</div>}>
              <DataDictionary />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/eighth',
        children: [
          // 资产管理
          {
            path: '/home/eighth/assetsManagement',
            element: <Suspense fallback={<div>Loading...</div>}>
              <AssetsManagement />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/ninth',
        children: [
          // 分析报表
          {
            path: '/home/ninth/analyticalStatement',
            element: <Suspense fallback={<div>Loading...</div>}>
              <AnalyticalStatement />
            </Suspense>
          },
          // 分析报表: 供应商分析
          {
            path: '/home/ninth/vendorAnalysis',
            element: <Suspense fallback={<div>Loading...</div>}>
              <VendorAnalysis />
            </Suspense>
          },
          // 分析报表:合格率分析
          {
            path: '/home/ninth/yieldAnalysis',
            element: <Suspense fallback={<div>Loading...</div>}>
              <YieldAnalysis />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/tenth',
        children: [
          // 绩效管理
          {
            path: '/home/tenth/PerformanceManagement',
            element: <Suspense fallback={<div>Loading...</div>}>
              <PerformanceManagement />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/eleventh',
        children: [
          // 权限管理
          {
            path: '/home/eleventh/authorityManagement',
            element: <Suspense fallback={<div>Loading...</div>}>
              <AuthorityManagement />
            </Suspense>
          },
          // 权限管理:用户管理
          {
            path: '/home/eleventh/userControl',
            element: <Suspense fallback={<div>Loading...</div>}>
              <UserControl />
            </Suspense>
          },
          // 权限管理:邮件组管理
          {
            path: '/home/eleventh/mailManagement',
            element: <Suspense fallback={<div>Loading...</div>}>
              <MailManagement />
            </Suspense>
          },
          // 编辑的页面
          {
            path: '/home/eleventh/mailEditor',
            element: <Suspense fallback={<div>Loading...</div>}>
              <MailEditor />
            </Suspense>
          },
          // 权限管理:自动派件设置
          {
            path: '/home/eleventh/autoSingle',
            element: <Suspense fallback={<div>Loading...</div>}>
              <AutoSingle />
            </Suspense>
          },
        ]
      },
      {
        path: '/home/twelfth',
        children: [
          {
            path: '/home/twelfth/helpCenter',
            element: <Suspense fallback={<div>Loading...</div>}>
              <HelpCenter />
            </Suspense>
          }
        ]
      },

    ]
  },
  // 首页今日看板
  {
    path: '/todayBillboard',
    element: <Suspense fallback={<div>Loading...</div>}>
      <TodayBillboard />
    </Suspense>
  },
  //首页IQC质量管理看板
  {
    path: '/qualityBillboard',
    element: <Suspense fallback={<div>Loading...</div>}>
      <QualityBillboard />
    </Suspense>
  }
])

export default Routers